<template>
  <el-dropdown trigger="click" @command="handleSelect">
    <div>
      <svg-icon class-name="plus-icon" icon-class="plus" />
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item v-for="item of permiMenu" :key="item.value" :command="item">
        {{ item.label }}
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import auth from '@/plugins/auth'

export default {
  data() {
    return {
      options: [
        { label: '批量添加房源', value: '/house/batchAdd',permi:'house:house:batchAdd' },
      ]
    }
  },
  computed: {
    permiMenu() {
      return this.options.map(item => {
        item['disabled'] = !auth.hasPermi(item.permi)
        return item
      })
    }
  },
  methods: {
    handleSelect(data) {
      if(data.disabled){
        this.$message.error('没有权限,请联系管理员')
        return
      }
      this.$router.push(data.value)
    },
  }

}
</script>
